//
//  SportDetailVC.m
//  ChatOnLine
//
//  Created by dllo on 16/8/15.
//  Copyright © 2016年 WWT. All rights reserved.
//

#import "SportDetailVC.h"
#import "UIBarButtonItem+NavicationBar.h"
#import "WJDataManager.h"
#import "SportDetailCell.h"

@interface SportDetailVC ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) NSMutableArray *array;

@end

@implementation SportDetailVC

/** 第二个页面也要签协议 */
-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createConfig];
    
    [self createView];
    
}

- (void)createConfig
{

    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"Return" hightImage:@"ReturnClick" target:self action:@selector(popAction)];
}

- (void)popAction
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)createView
{
    self.tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    [self.view addSubview:self.tableView];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = SCREEN_HEIGHT / 3 + 50;
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.bounces = NO;
    
    [self.tableView registerClass:[SportDetailCell class] forCellReuseIdentifier:@"sportDetailCell"];
    
    self.array = [[WJDataManager shareFMDB]selectAll];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SportDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"sportDetailCell" forIndexPath:indexPath];
    
    if (self.array.count > 0) {
        cell.detailArray = self.array[indexPath.row];
    }
    
    return cell;
}












@end
